﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Windows.Controls.Ribbon;
using ProggersWTC.Views;

namespace ProggersWTC
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : RibbonWindow
    {
        public Page CurrentPage { get; set; }

        public MainWindow()
        {
            InitializeComponent();

            // Insert code required on object creation below this point.
            CurrentPage = null;
        }

        private void Ribbon_OnTabClick(object sender, SelectionChangedEventArgs e)
        {
            Ribbon ribbon = (Ribbon)sender;
            RibbonTab ribbonTab = (RibbonTab)ribbon.SelectedItem;
            String uri = String.Empty;

            switch (ribbonTab.Name)
            {
                case "ledenBeheerTab":
                    uri = "Views/SpelerViews/SpelerPage.xaml";
                    break;
                case "boekhoudingTab":
                    uri = "Views/BoekhoudingViews/BoekhoudingPage.xaml";
                    break;
                case "ploegenTab":
                    uri = "Views/PloegenViews/PloegenPage.xaml";
                    break;
                case "wedstrijdenTab":
                    uri = "Views/WedstrijdenViews/WedstrijdenPage.xaml";
                    break;
                default:
                    uri = String.Empty;
                    break;
            }

            if (uri != String.Empty)
            {
                mainFrame.Source = new Uri(uri, UriKind.RelativeOrAbsolute);
            }

        }

        private void afsluitenMenuItem_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void mainFrame_LoadCompleted(object sender, NavigationEventArgs e)
        {
            CurrentPage = (Page)e.Content;
        }

        private void spelerRibbonButton_Click(object sender, RoutedEventArgs e)
        {
            Views.SpelerViews.SpelerPage page = (Views.SpelerViews.SpelerPage)CurrentPage;

            RibbonButton btn = (RibbonButton)sender;
            switch (btn.Name)
            {
                case "addSpelerRibbonButton":
                    page.AddSpeler();
                    break;
                case "editSpelerRibbonButton":
                    page.EditSpeler();
                    break;
                case "deleteSpelerRibbonButton":
                    page.RemoveSpeler();
                    break;
                default:
                    break;
            }
        }

        private void ploegRibbonButton_Click(object sender, RoutedEventArgs e)
        {
            Views.PloegenViews.PloegenPage page = (Views.PloegenViews.PloegenPage)CurrentPage;

            RibbonButton btn = (RibbonButton)sender;
            switch (btn.Name)
            {
                case "addPloegRibbonButton":
                    page.AddPloeg();
                    break;
                case "editPloegRibbonButton":
                    page.ChangePloeg();
                    break;
                case "deletePloegRibbonButton":
                    page.DeletePloeg();
                    break;
                default:
                    break;
            }
        }

        private void boekhoudRibbonButton_Click(object sender, RoutedEventArgs e)
        {
            ((Views.BoekhoudingViews.BoekhoudingPage)CurrentPage).BerekenKostSpeler();
        }
    }
}
